local qinrong = fk.CreateSkill{
  name = "xiaobai__qinrong",
}

Fk:loadTranslationTable{
  ["xiaobai__qinrong"] = " 亲戎",
  [":xiaobai__qinrong"] = "摸牌阶段，你可以改为视为使用一张【远交近攻】，然后你与此牌的目标议事，若议事有结果，其变更势力至与你相同。",
  ["#xiaobai__qinrong_prompt"] = "亲戎：你可以放弃摸牌改为视为使用一张【远交近攻】，然后你与此牌的目标议事，若议事有结果，其变更势力至与你相同。",
}

local U = require "packages.utility.utility"

qinrong:addEffect(fk.DrawNCards, {
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(self) and target == player
  end,
  on_cost = function (self, event, target, player, data)
    local use = player.room:askToUseVirtualCard(player, {
      name = "befriend_attacking", 
      skill_name = qinrong.name,
      prompt =  "#xiaobai__qinrong_prompt",
      skip = true,})
    if use then
      event:setCostData(self, use)
      return true
    end
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    data.n = 0
    local cost_data = event:getCostData(self) ---@type UseCardDataSpec
    room:useCard(cost_data)
    if player.dead then return end
    local target = cost_data.tos[1]
    local discussion = U.Discussion(player, {player, target}, qinrong.name)
    if target.dead then return true end
    if discussion.color ~= "noresult" then
      room:changeKingdom(target, player.kingdom)
    end
    return true
  end
})

return qinrong